#!/opt/local/bin/perl
use strict;
use warnings;
use LastFM::API;

my $musicDir = shift ||  die "Usage: getTopTracks.pl MusicDir e.g. ../Music\n";

my ($dataBase,$allTags) = getTagDatabase($musicDir);
my $artists = getArtists($dataBase);

foreach my $a (@$artists){
  print "$a\n";
  my $test = getTopTracks($a);
  ### Print the top tracks that we have in our library
  my @inL;
  map {my $there=inLibrary($dataBase,$a,$_);push(@inL,$there) if $there; } keys %$test;
  map {print "$_\n"} @inL;
}
